import os

import pytest
import requests
from selenium import webdriver


@pytest.fixture(scope='session')
def movie_login():
    url='http://10.59.9.18/movieApi/user/v2/login'
    body={
        'email':'3601552946@qq.com',
        'pwd':'eWLPHopE945d2ivttHaQTQ=='
    }
    r=requests.post(url,data=body,timeout=5)
    print(r.json())
    yield r.json()['result']['userId'],r.json()['result']['sessionId']

@pytest.fixture(scope='function')
def getdriver():
    driver=None
    if 'chrome' == os.getenv('drivertype'):
        driver = webdriver.Chrome()
    if driver is None:
        print('没有匹配的浏览器')
        return
    driver.maximize_window()
    driver.implicitly_wait(5)
    yield driver
    driver.close()